<style scoped src="./index.scss" lang="scss" rel="stylesheet/scss"></style>
<template src="./index.html"></template>
<script>
export default {
  mixins: [
    Vue.prototype.$vFN.Mixins.Base,
    Vue.prototype.$vFN.Mixins.Page,
    Vue.prototype.$vFN.Mixins.Table,
  ],
  data() {
    return {
      appWindow: window,
      // 页面接口地址
      apiUrl: {
        list: "mall-site-portal/member-money-withdraw/list",
      },
      // 状态选择
      stateList: [
        "全部状态",
        "待审核",
        "待打款",
        "打款中",
        "已放款",
        "已驳回",
        "无效提现",
      ],
      withdrawStatus: "",
      // 提现方式
      withdrawlList: ["全部提现方式", "微信", "银行卡"],
      withdrawType: "",
      // 表格查询数据
      mixinTable_tableSearchData: {
        createdTimeStartStr: "",
        createdTimeEndStr: "",
        memberInfo: "",
        withdrawStatus: "",
        withdrawType: "",
      },
      // 表格数据
      tableData: [],
      // 选择日期的值
      timeValue1: [],

      // 提现的统计数据
      countData: null,
    };
  },
  methods: {
    // 确认放款
    async paymentConfirm(r) {
      // 打开加载遮罩层
      this.$vFN.Tools.setLoad(true);
      let _d = await import("@/directives/AffirmPayment/index");
      // 关闭加载遮罩层
      this.$vFN.Tools.setLoad(false);
      _d.default.init({
        id: r.id,
        type: r.type,
        onSuccess: (r) => {
          this.mixinTable_refreshData();
        },
        onCancel: () => {
          this.mixinTable_refreshData();
        },
      });
    },

    //  审批操作
    async userOperating(r) {
      // 打开加载遮罩层
      this.$vFN.Tools.setLoad(true);
      let _d = await import("@/directives/Operating/index");
      // 关闭加载遮罩层
      this.$vFN.Tools.setLoad(false);
      _d.default.init({
        item_id: r,
        onSuccess: (r) => {
          this.mixinTable_refreshData();
        },
      });
    },

    // 申请状态转换文字
    transformText(number) {
      let text = "";
      switch (number) {
        case 1:
          text = "待审核";
          break;
        case 2:
          text = "待打款";
          break;
        case 3:
          text = "打款中";
          break;
        case 4:
          text = "已放款";
          break;
        case 5:
          text = "已驳回";
          break;
        case 6:
          text = "无效提现";
          break;

        default:
          text = "无";
      }

      return text;
    },

    // 时间选择
    async timeSelect(times) {
      if (times !== null) {
        let startStr = this.$vFN.Utils.timestampToDate(
          "yyyy-MM-dd",
          times[0].getTime()
        );
        let endStr = this.$vFN.Utils.timestampToDate(
          "yyyy-MM-dd",
          times[1].getTime()
        );
        this.mixinTable_tableSearchData.createdTimeStartStr = startStr;
        this.mixinTable_tableSearchData.createdTimeEndStr = endStr;
      } else {
        this.mixinTable_tableSearchData.createdTimeStartStr = "";
        this.mixinTable_tableSearchData.createdTimeEndStr = "";
      }

      this.getListCount();
      this.mixinTable_getTable();
    },

    // 提现方式
    async clickWithdrawa(index) {
      if (index !== 0) {
        this.mixinTable_tableSearchData.withdrawType = index;
      } else {
        this.mixinTable_tableSearchData.withdrawType = "";
      }

      this.getListCount();
      this.mixinTable_getTable();
    },

    // 获取提现的概况
    async getListCount() {
      let res = await this.$vFN.Http.post(
        {
          url: "mall-site-portal/member-money-withdraw/listCount",
          data: {
            ...this.mixinTable_tableSearchData,
          },
        },
        window
      );

      if (res._ok) {
        console.log(res);
        this.countData = res.data;
      }
    },

    inputSearch() {
      this.getListCount();
      this.mixinTable_searchData();
    },

    //  状态选择
    async clickState(index) {
      if (this.stateList[index] !== "全部") {
        this.mixinTable_tableSearchData.withdrawStatus = index;
      } else {
        this.mixinTable_tableSearchData.withdrawStatus = "";
      }

      this.getListCount();
      this.mixinTable_getTable();
    },

    getWithdrawType(num) {
      let text = "";
      switch (num) {
        case 1:
          text = "微信";
          break;
        case 2:
          text = "银行卡";
          break;
        case 3:
          text = "支付宝";
          break;
      }

      return text;
    },

    // 初始化
    async init() {
      this.getListCount();
      this.mixinTable_refreshData();
    },
  },
  mounted() {
    this.init();
  },
  activated() {},
};
</script>